/**
 * @product: AFP
 * @copyright: FSAI-南征北战信息科技
 * @filename: com.sod.pojo.BaseResp.java
 *
 * @link: Http://www.fastsai.com
 * @jdkv: Jdk 1.8
 */
package com.fsai.cms.base;

/**
 *
 * @project: sod-entity
 *
 * @author: JaffeHe
 * @email: JaffeHe@foxmail.com
 * @date: 2020-06-04 23:14
 *
 * @ChangeLog<br/>
 * 				Developer Date Comment <br/>
 */
public class BaseResp {

	private int code;
	private String message;
	private Object data;

	/**
	 * @return the code
	 */
	public int getCode() {
		return code;
	}

	/**
	 * @param code
	 *            the code to set
	 */
	public void setCode(int code) {
		this.code = code;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @param message
	 *            the message to set
	 */
	public void setMessage(String message) {
		this.message = message;
	}

	/**
	 * @return the data
	 */
	public Object getData() {
		return data;
	}

	/**
	 * @param data
	 *            the data to set
	 */
	public void setData(Object data) {
		this.data = data;
	}

	public static BaseResp holderResp(int code, String message, Object data) {
		BaseResp baseResp = new BaseResp();
		baseResp.setCode(code);
		baseResp.setMessage(message);
		baseResp.setData(data);

		return baseResp;
	}

	public static BaseResp success(Object data) {
		return holderResp(WebCons.SUCCESS_RESP_CODE, "提示：执行操作成功", data);
	}

	public static BaseResp successMsg(String msg, Object data) {
		return holderResp(WebCons.SUCCESS_RESP_CODE, msg, data);
	}

	public static BaseResp errorData(Object data) {
		return holderResp(WebCons.ERROR_RESP_CODE, "警告：出了小错", data);
	}

	public static BaseResp errorMsg(String msg) {
		return holderResp(WebCons.ERROR_RESP_CODE, msg, "");
	}

}
